﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Olympic_email_to_future.Module;
using Olympic_email_to_future.IDAL;


namespace Olympic_email_to_future.DAL
{
    class AttachmentDAL : IAttachmentInfo
    {
        AttachmentInfoDataContext ctx = new AttachmentInfoDataContext("Data Source=LHX\\SQLEXPRESS;Initial Catalog=Olympic;Integrated Security=True");


        /*******************************************************************
         * * 函数名称：getAttachmentInfoByMailId
         * * 功    能：通过mailid得到该mail的所有attachmentinfo
         * * 参    数：
         * * 返 回 值：
         * * 作    者：LHX
         * * 日    期：2013年6月8日
         * *******************************************************************/
        public IList<AttachmentInfo> getAttachmentInfoByMailId(int mailid)
        {
            IList<AttachmentInfo> attlist = new List<AttachmentInfo>();

            var result = from att in ctx.AttachmentInfo  where att.emailId==mailid select att;
            foreach (AttachmentInfo att in result)
            {
                attlist.Add(att);
            }

            return attlist;
        }





        public void insertAttmentInfo(AttachmentInfo att)
        {
            ctx.AttachmentInfo.InsertOnSubmit(att);
            ctx.SubmitChanges();
        }
    }
}
